#include <iostream>

int main() {
    int arr[3][4] = {
        {3, 5, 6, 7},
        {12, 1, 1, 1},
        {0, 7, 12, 1}
    };

    int rowSum1 = 0, rowSum2 = 0, rowSum3 = 0;
    int colSum1 = 0, colSum2 = 0, colSum3 = 0, colSum4 = 0;
    int totalSum = 0;

    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 4; ++j) {
            totalSum += arr[i][j];
            if (i == 0) rowSum1 += arr[i][j];
            if (i == 1) rowSum2 += arr[i][j];
            if (i == 2) rowSum3 += arr[i][j];
            if (j == 0) colSum1 += arr[i][j];
            if (j == 1) colSum2 += arr[i][j];
            if (j == 2) colSum3 += arr[i][j];
            if (j == 3) colSum4 += arr[i][j];
        }
    }

    std::cout << arr[0][0] << " " << arr[0][1] << " " << arr[0][2] << " " << arr[0][3] << " | " << rowSum1 << std::endl;
    std::cout << arr[1][0] << " " << arr[1][1] << " " << arr[1][2] << " " << arr[1][3] << " | " << rowSum2 << std::endl;
    std::cout << arr[2][0] << " " << arr[2][1] << " " << arr[2][2] << " " << arr[2][3] << " | " << rowSum3 << std::endl;
    std::cout << "--------------------" << std::endl;
    std::cout << colSum1 << " " << colSum2 << " " << colSum3 << " " << colSum4 << " | " << totalSum << std::endl;

    return 0;
}

